<template>
  <div>
    <mt-header fixed title="道路货物运输量专项调查" style="z-index: 999999;">
      <span slot="left" @click="goBack">
        <mt-button icon="back" slot="left">返回</mt-button>
      </span>
      <mt-button v-if="(reportedByOther==1&&information=='调查员'||reportedByOther==0&&information=='业户')" icon slot="right" @click.native="insertDate">新增</mt-button>
    </mt-header>
    <el-table border :data="tableData4" style="width: 100%" max-height="450">
      <el-table-column fixed prop="xh" label="序号" width="50" align="center"></el-table-column>
      <el-table-column prop="cphm" label="车牌号码" width="90" align="center"></el-table-column>
      <el-table-column prop="cpys" label="车牌颜色" width="90" align="center"></el-table-column>
      <el-table-column prop="rq" label="日期" width="105" align="center"></el-table-column>
      <el-table-column prop="tcs" label="趟次数(个)" width="80" align="center"></el-table-column>
      <el-table-column prop="hyl" label="货运量(吨)" width="80" align="center"></el-table-column>
      <el-table-column prop="hyzzl" label="货运周转量(吨公里)" width="80" align="center"></el-table-column>
      <el-table-column prop="pjyj" label="平均运距（公里）" width="120" align="center"></el-table-column>
      <el-table-column prop="jzxxyl" label="集装箱箱运量(TEU)" width="120" align="center"></el-table-column>
      <el-table-column prop="hlymc" label="货类1名称" width="80" align="center"></el-table-column>
      <el-table-column prop="hlyhyl" label="货类1货运量（吨）" width="120" align="center"></el-table-column>
      <el-table-column prop="hlermc" label="货类2名称" width="80" align="center"></el-table-column>
      <el-table-column prop="hlerhyl" label="货类2货运量（吨）" width="120" align="center"></el-table-column>
      <el-table-column prop="hlsmc" label="货类3名称" width="80" align="center"></el-table-column>
      <el-table-column prop="hlshyl" label="货类3货运量（吨）" width="120" align="center"></el-table-column>
      <el-table-column label="操作" width="120" align="center">
        <template slot-scope="scope">
          <el-button
            v-if="(reportedByOther==1&&information=='调查员'||reportedByOther==0&&information=='业户')"
            @click.native.prevent="deleteRow(scope.$index, tableData4)"
            type="text"
            size="small"
          >移除</el-button>
          <el-button v-if="(reportedByOther==1&&information=='调查员'||reportedByOther==0&&information=='业户')" @click.native.prevent="updateRow(scope.$index)" type="text" size="small">修改</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-table
      border
      :data="tableData6"
      style="width: 100%"
      max-height="200"
      :span-method="objectSpanMethod">
      <el-table-column prop="zb" label="指标" width="60" align="center"></el-table-column>
      <el-table-column prop="alltcs" label="趟次数(个)" width="80" align="center"></el-table-column>
      <el-table-column prop="allhyl" label="货运量（吨）" width="80" align="center"></el-table-column>
      <el-table-column prop="allhyzzl" label="货物周转量(吨公里)" width="80" align="center"></el-table-column>
      <el-table-column prop="alljzxxyl" label="集装箱箱运量(TEU)" width="80" align="center"></el-table-column>
      <el-table-column prop="allhl" label="货类" width="110" align="center"></el-table-column>
      <el-table-column prop="mtjzp" label="煤炭及制品" width="110" align="center"></el-table-column>
      <el-table-column prop="jsks" label="金属矿石" width="110" align="center"></el-table-column>
      <el-table-column prop="kjcljsn" label="扩建材料及水泥" width="110" align="center"></el-table-column>
      <el-table-column prop="jxsbdq" label="机械设备电器" width="110" align="center"></el-table-column>
      <el-table-column prop="qgyycp" label="轻工医药产品" width="110" align="center"></el-table-column>
      <el-table-column prop="xhncp" label="鲜活农产品" width="110" align="center"></el-table-column>
      <el-table-column prop="qt" label="其他" width="110" align="center"></el-table-column>
    </el-table>
    <table >
            <tr v-for = 'item in errorMessage'>
                <td style="color:blue">{{item}}</td>
            </tr>
        </table>
  </div>
</template>
      
      <script>
      import {Toast} from 'mint-ui'
export default {
  data() {
    return {
      errorMessage: [],
      xh: 0, //序号
      tableData6: [
        {
          zb: "合计",
          alltcs: "", //趟次数（个）
          allhyl: "", // 货运量（吨）
          allhyzzl: "", // 货运周转量（吨）
          alljzxxyl: "", // 集装箱箱运量（TEU）
          allhl: "货运量（吨）", // 货类货运量（吨）
          mtjzp: "", // 煤炭及制品
          jsks: "", // 金属矿石
          kjcljsn: "", // 矿建材料及水泥
          jxsbdq: "", // 机械设备电器
          qgyycp: "", // 轻工医药产品
          xhncp: "", //鲜活农产品
          qt: "" // 其他
        },
        {
          zb: "合计",
          alltcs: "",
          allhyl: "",
          allhyzzl: "",
          alljzxxyl: "",
          allhl: "周转量（吨公里）",
          mtjzp: "",
          jsks: "",
          kjcljsn: "",
          jxsbdq: "",
          qgyycp: "",
          xhncp: "",
          qt: ""
        }
      ],
      tableData4: [
        {
          recid: "",
          floatorder: "",
          xh: 0,
          cphm: "", // 车牌号码
          cpys: "", // 车牌颜色
          rq: "", // 日期
          tcs: "", //趟次数（个）
          hyl: "", // 货运量(吨)
          hyzzl: "", // 货运周转量(吨公里)
          pjyj: "", //平均运距（公里）
          jzxxyl: "", //集装箱箱运量(TEU)
          hlymc: "", // 货类1名称
          hlyhyl: "", // 货类1货运量（吨）
          hlermc: "", // 货类2名称
          hlerhyl: "", // 货类2货运量（吨）
          hlsmc: "", // 货类3名称
          hlshyl: "" // 货类3货运量
        }
      ],
      // 根据公司状态判定新增按钮是否显示 add by qzn 20190625
      reportedByOther: this.$route.query.reportedByOther,
      information: this.$route.query.information,

    };
  },
  watch: {},
  mounted() {
    this.getCode();
  },
  methods: {
    allgetCode() {
      let alltcs = 0;
      let allhyl = 0;
      let allhyzzl = 0;
      let alljzxxyl = 0;
      //
      let mtjzp0 = 0;
      let jsks0 = 0;
      let kjcljsn0 = 0;
      let jxsbdq0 = 0;
      let qgyycp0 = 0;
      let xhncp0 = 0;
      let qt0 = 0;
      //
      let mtjzp = 0;
      let jsks = 0;
      let kjcljsn = 0;
      let jxsbdq = 0;
      let qgyycp = 0;
      let xhncp = 0;
      let qt = 0;
      this.tableData4.forEach(item => {
        if(item.tcs != undefined && item.tcs != ""){
            alltcs += parseFloat(item.tcs); // 总趟次
        }
        if(item.hyl != undefined && item.hyl != ""){
            allhyl += parseFloat(item.hyl); // 总的货运量
            if(item.pjyj != undefined && item.pjyj != ""){
              allhyzzl += parseFloat(item.hyl) * parseFloat(item.pjyj); // 总的平均运距
            }
        }
        if(item.jzxxyl != "" && item.jzxxyl != undefined){
            alljzxxyl += parseInt(item.jzxxyl); // 总的集装箱箱运量
        }
        
        // 计算煤炭及制货运量
        if (item.hlymc == "煤炭及制品" && item.hlyhyl != undefined) {
          mtjzp0 += parseFloat(item.hlyhyl);
        } else if (item.hlermc == "煤炭及制品" && item.hlerhyl != undefined) {
          mtjzp0 += item.hlerhyl;
        } else if (item.hlsmc === "煤炭及制品" && item.hlshyl != undefined) {
          mtjzp0 += item.hlshyl;
        }
        // 金属及矿石货运量
        if (item.hlymc == "金属矿石" && item.hlyhyl != undefined) {
          jsks0 += parseFloat(item.hlyhyl);
        } else if (item.hlermc == "金属矿石" && item.hlerhyl != undefined) {
          jsks0 += item.hlerhyl;
        } else if (item.hlsmc === "金属矿石" && item.hlshyl != undefined) {
          jsks0 += item.hlshyl;
        }
        // 矿建材料及水泥货运量
        if (item.hlymc == "矿建材料及水泥" && item.hlyhyl != undefined) {
          kjcljsn0 += parseFloat(item.hlyhyl);
        } else if (item.hlermc == "矿建材料及水泥" && item.hlerhyl != undefined) {
          kjcljsn0 += item.hlerhyl;
        } else if (item.hlsmc === "矿建材料及水泥" && item.hlshyl != undefined) {
          kjcljsn0 += item.hlshyl;
        }
        // 机械设备电气货运量
        if (item.hlymc == "机械设备电器" && item.hlyhyl != undefined) {
          jxsbdq0 += parseFloat(item.hlyhyl);
        } else if (item.hlermc == "机械设备电器" && item.hlerhyl != undefined) {
          jxsbdq0 += item.hlerhyl;
        } else if (item.hlsmc === "机械设备电器" && item.hlshyl != undefined) {
          jxsbdq0 += item.hlshyl;
        }
        // 轻工医药产品
        if (item.hlymc == "轻工医药产品" && item.hlyhyl != undefined) {
          qgyycp0 += parseFloat(item.hlyhyl);
        } else if (item.hlermc == "轻工医药产品" && item.hlerhyl != undefined) {
          qgyycp0 += item.hlerhyl;
        } else if (item.hlsmc === "轻工医药产品" && item.hlshyl != undefined) {
          qgyycp0 += item.hlshyl;
        }
        // 鲜活农产品
        if (item.hlymc == "鲜活农产品" && item.hlyhyl != undefined) {
          xhncp0 += parseFloat(item.hlyhyl);
        } else if (item.hlermc == "鲜活农产品" && item.hlerhyl != undefined) {
          xhncp0 += item.hlerhyl;
        } else if (item.hlsmc === "鲜活农产品" && item.hlshyl != undefined) {
          xhncp0 += item.hlshyl;
        }
        // 其他
        if (item.hlymc == "其他" && item.hlyhyl != undefined) {
          qt0 += parseFloat(item.hlyhyl);
        } else if (item.hlermc == "其他" && item.hlerhyl != undefined) {
          qt0 += item.hlerhyl;
        } else if (item.hlsmc === "其他" && item.hlshyl != undefined) {
          qt0 += item.hlshyl;
        }
      });
      this.tableData6[0].alltcs = alltcs;
      this.tableData6[0].allhyl = allhyl;
      this.tableData6[0].allhyzzl = allhyzzl;
      this.tableData6[0].alljzxxyl = alljzxxyl;
      //
      this.tableData6[0].mtjzp = mtjzp0;
      this.tableData6[0].jsks = jsks0;
      this.tableData6[0].kjcljsn = kjcljsn0;
      this.tableData6[0].jxsbdq = jxsbdq0;
      this.tableData6[0].qgyycp = qgyycp0;
      this.tableData6[0].xhncp = xhncp0;
      this.tableData6[0].qt = qt0;
      //
      // this.tableData6[1].mtjzp = mtjzp;
      // this.tableData6[1].jsks = jsks;
      // this.tableData6[1].kjcljsn = kjcljsn;
      // this.tableData6[1].jxsbdq = jxsbdq;
      // this.tableData6[1].qgyycp = qgyycp;
      // this.tableData6[1].xhncp = xhncp;
      // this.tableData6[1].qt = qt;
      //console.log(this.tableData6[0].mtjzp);
      this.saveData();
    },
    goBack() {
      //点击后退
      this.$router.go(-1);
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (
        columnIndex === 0 ||
        columnIndex === 1 ||
        columnIndex === 2 ||
        columnIndex === 3 ||
        columnIndex === 4
      ) {
        if (rowIndex % 2 === 0) {
          return {
            rowspan: 2,
            colspan: 1
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      }
    },
    getCode() {
      let data = {};
      data.yhmlkRecid = this.$route.query.yhmlk;
      // console.log("yhmlkRecid-->" + data.yhmlkRecid);
      this.axios
        .post(
          "http://zxdc.catsic.com:9090/sampling/assit/findFzdcbfd02",
          { data: data },
          {
            headers: {
              "Content-Type": "application/json",
              mobileHeader:
                '{"sessionId":' + localStorage.getItem("sessionId") + "}"
            }
          }
        )
        .then(
          result => {
            if (result.data.status == "1000") {
               console.log("辅助表2获取数据result-->>"+JSON.stringify(result))
              this.tableData4.splice(0);
              if( result.data.data.MSG != "没有查询到结果"){
                this.xh = 0;
                  result.data.data.Fzdcbfd02.forEach(item => {
                  let tableData = {};
                  tableData.recid = item.recid;
                  tableData.floatorder = item.floatorder;
                  tableData.xh = ++this.xh;
                  (tableData.cphm = item.fzdcbfd22019001), // 车牌号码
                  (tableData.cpys = this.getCarColorName(item.plateColorCode)), // 车牌颜色
                  (tableData.rq = item.fzdcbfd22019002), // 日期
                  (tableData.tcs = item.fzdcbfd22019003), // 趟次数
                  (tableData.hyl = item.fzdcbfd22019004), // 货运量
                  (tableData.hyzzl = item.fzdcbfd22019005), // 货运周转量
                  (tableData.pjyj = item.fzdcbfd22019006), // 平均运距
                  (tableData.jzxxyl = item.fzdcbfd22019007), // 将装箱箱运量
                  (tableData.hlymc = this.getGoodsTypeNmae(item.fzdcbfd22019008)), // 货类1名称
                  (tableData.hlyhyl = item.fzdcbfd22019009), // 货类1货运量
                  (tableData.hlermc = this.getGoodsTypeNmae(item.fzdcbfd22019010)), // 货类2名称
                  (tableData.hlerhyl = item.fzdcbfd22019011), // 货类2货运量
                  (tableData.hlsmc = this.getGoodsTypeNmae(item.fzdcbfd22019012)), // 货类3名称
                  (tableData.hlshyl = item.fzdcbfd22019013), // 货类三货运量
                  this.tableData4.push(tableData);
                  if(tableData.cphm == ""){
                      this.errorMessage.push("序号"+tableData.xh+" 提示性错误：车牌号码不能为空，请修改！");
                  }
                  if(tableData.cpys == "" || tableData.cpys == undefined){
                      this.errorMessage.push("序号"+tableData.xh+" 提示性错误：车牌颜色不能为空，请修改！");
                  }
                  if(tableData.rq == "" || tableData.rq == undefined){
                      this.errorMessage.push("序号"+tableData.xh+" 提示性错误：日期不能为空，请修改！");
                  }
                  if(tableData.tcs == "" || tableData.tcs == undefined){
                      this.errorMessage.push("序号"+tableData.xh+" 提示性错误：趟次数不能为空，请修改！");
                  }
                  if(tableData.hyl == "" || tableData.hyl == undefined){
                      this.errorMessage.push("序号"+tableData.xh+" 提示性错误：货运量不能为空，请修改！");
                  }
                  if((tableData.hyzzl == "" || tableData.hyzzl == undefined) && (tableData.pjyj == "" || tableData.pjyj == undefined)){
                      this.errorMessage.push("序号"+tableData.xh+" 提示性错误：单趟次货物周转量和平均运距其中一项不能为空，请修改！");
                  }
                  //[JUI6HUY6][FZB2]F23
                  if(tableData.pjyj != "" && tableData.pjyj != undefined){
                    if(parseFloat(tableData.pjyj)>4500){
                        this.errorMessage.push("序号"+tableData.xh+" 提示性错误：平均运距应小于等于4500，请修改！");
                    }
                  }
                  //[JUI6HUY6][FZB2]F21
                  if(tableData.hyl != "" && tableData.hyl != undefined && tableData.tcs != "" && tableData.tcs != undefined){
                    if(parseFloat(tableData.hyl)>0 && parseFloat(tableData.tcs)>0){
                      if((parseFloat(tableData.hyl)/parseFloat(tableData.tcs)) > 150){
                        this.errorMessage.push("序号"+tableData.xh+" 提示性错误：单趟次平均运量应小于等于150，请修改！");
                      }
                    }
                  }
                  //[JUI6HUY6][FZB2]F22
                  if(tableData.hyzzl != "" && tableData.hyzzl != undefined && tableData.hyl != "" && tableData.hyl != undefined
                    && tableData.pjyj != "" && tableData.pjyj != undefined){
                      if(parseFloat(tableData.hyzzl)>0 && parseFloat(tableData.hyl)>0){
                        let result = parseFloat(tableData.hyzzl)/parseFloat(tableData.hyl);
                        if(result > (parseFloat(tableData.pjyj)+0.1) || result < (parseFloat(tableData.pjyj)-0.1)){
                          this.errorMessage.push("序号"+tableData.xh+" 提示性错误：单趟次货物周转量除以单趟次运量应大于平均运距减0.1且小于平均运距加0.1，请修改！");
                        }
                      }
                  }
                  if(tableData.hlymc==undefined){tableData.hlymc=""}
                  if(tableData.hlermc==undefined){tableData.hlermc=""}
                  if(tableData.hlsmc==undefined){tableData.hlsmc=""}
                  if(tableData.hyl==undefined){tableData.hyl=""}
                  if(tableData.hlyhyl==undefined){tableData.hlyhyl=""}
                  if(tableData.hlerhyl==undefined){tableData.hlerhyl=""}
                  if(tableData.hlshyl==undefined){tableData.hlshyl=""}
                  //[JUI6HUY6][FZB2]F24
                  if(tableData.hlymc == "" || tableData.hlyhyl==""){
                    this.errorMessage.push("序号"+tableData.xh+" 提示性错误：货类1名称和货类1货运量不能为空，请修改！");
                  }
                  if(tableData.hlymc != '' && tableData.hlermc !='' && tableData.hlymc == tableData.hlermc){
                    this.errorMessage.push("序号"+tableData.xh+" 提示性错误：货类1名称和货类2名称重复，请修改！");
                  }
                  //[JUI6HUY6][FZB2]F25
                  if(tableData.hlermc !='' && (tableData.hlerhyl == "" || tableData.hlerhyl == "0")){
                    this.errorMessage.push("序号"+tableData.xh+" 提示性错误：有货类2名称，货类2货运量应大于零，请修改！");
                  }
                  if(tableData.hlymc != '' && tableData.hlsmc !='' && tableData.hlymc == tableData.hlsmc){
                      this.errorMessage.push("序号"+tableData.xh+" 提示性错误：货类1名称和货类3名称重复，请修改！");
                  }
                  if(tableData.hlermc != '' && tableData.hlsmc !='' && tableData.hlermc == tableData.hlsmc){
                      this.errorMessage.push("序号"+tableData.xh+" 提示性错误：货类2名称和货类3名称重复，请修改！");
                  }  
                  //[JUI6HUY6][FZB2]F36
                  if(tableData.hlsmc !='' && (tableData.hlshyl == "" || tableData.hlshyl == "0")){
                    this.errorMessage.push("序号"+tableData.xh+" 提示性错误：有货类3名称，货类3货运量应大于零，请修改！");
                  }             
                  if(parseFloat(tableData.hyl==""?0:tableData.hyl) != (parseFloat(tableData.hlyhyl==""?0:tableData.hlyhyl) + parseFloat(tableData.hlerhyl==""?0:tableData.hlerhyl)+parseFloat(tableData.hlshyl==""?0:tableData.hlshyl))){
                      this.errorMessage.push("序号"+tableData.xh+" 提示性错误：货运量应等于个货类货运量之和，请修改！");
                  }
              });
              }
              
            }
            this.allgetCode();
          },
          error => {
            console.log("getyhcars request error:" + error);
          }
        );
      // console.log(this.$route.query.yhmlk);
    },
    insertDate() {
      this.$router.push({
        path: "/home/auxiliaryTableTwoInsert/:yhmlk",
        query: { yhmlk: this.$route.query.yhmlk }
      });
    },
    deleteRow(index) {
      let data = {};
      data.recid = this.tableData4[index].recid;
      this.axios
        .post(
          "http://zxdc.catsic.com:9090/sampling/assit/deleteFzdcbfd02",
          { data: data },
          {
            headers: {
              "Content-Type": "application/json",
              mobileHeader:
                '{"sessionId":' + localStorage.getItem("sessionId") + "}"
            }
          }
        )
        .then(
          result => {
            if (result.data.status == "1000") {
              this.getCode();
              // console.log(result);
            }
          },
          error => {
            console.log("getyhcars request error:" + error);
          }
        );
      console.log(index, this.tableData4[index]);
      this.getCode();
    },
    updateRow(index) {
      this.$router.push({
        path: "/home/auxiliaryTableTwoUpdate/:yhmlk/:recid/:floatorder",
        query: {
          yhmlk: this.$route.query.yhmlk,
          recid: this.tableData4[index].recid,
          floatorder: this.tableData4[index].floatorder
        }
      });
      // console.log(index, this.tableData4[index]);
    },
    //保存固定行数据
    saveData() {
                let data = {};
                let fzdcbfd02Total = {};
                //localStorage.setItem('fzb2recid', "");
                console.log(localStorage.getItem(this.$route.query.yhmlk+"fzb2recid")+"-------");
                if(localStorage.getItem(this.$route.query.yhmlk+"fzb2recid")!=null){
                  fzdcbfd02Total.recid = localStorage.getItem(this.$route.query.yhmlk+"fzb2recid");    
                } else {
                  fzdcbfd02Total.recid = '';
                }

                fzdcbfd02Total.yhmlk = this.$route.query.yhmlk;

                fzdcbfd02Total.fzdcbgd22019001 = this.tableData6[0].alltcs;
                fzdcbfd02Total.fzdcbgd22019002 = this.tableData6[0].allhyl;
                fzdcbfd02Total.fzdcbgd22019003 = this.tableData6[0].allhyzzl;
                fzdcbfd02Total.fzdcbgd22019004 = this.tableData6[0].alljzxxyl;

                fzdcbfd02Total.fzdcbgd22019005 = this.tableData6[0].mtjzp;              
                fzdcbfd02Total.fzdcbgd22019007 = this.tableData6[0].jsks;            
                fzdcbfd02Total.fzdcbgd22019009 = this.tableData6[0].kjcljsn;              
                fzdcbfd02Total.fzdcbgd22019011 = this.tableData6[0].jxsbdq;
                fzdcbfd02Total.fzdcbgd22019013 = this.tableData6[0].qgyycp;
                fzdcbfd02Total.fzdcbgd22019015 = this.tableData6[0].xhncp;
                fzdcbfd02Total.fzdcbgd22019017 = this.tableData6[0].qt;   

                data.fzdcbfd02Total = fzdcbfd02Total;
                
                // console.log("2保存总计发送"+JSON.stringify(data));
                this.axios.post('http://zxdc.catsic.com:9090/sampling/assit/addFzdcbfd02Total', {'data': data}, {
                    'headers': {
                        'Content-Type': 'application/json',
                        'mobileHeader': '{"sessionId":' + localStorage.getItem('sessionId') + '}'
                    }
                }).then(result => {
                    // console.log("保存总计返回"+JSON.stringify(result));
                    if (result.data.status == "1000") {
                        Toast({
                            message: "保存成功",
                        });
                        if( result.data.data.MSG == "新增分车分日期记录表总计成功"){
                            localStorage.setItem(this.$route.query.yhmlk+'fzb2recid', result.data.data.gdRecid);
                        }
                        //console.log("fzb1recid"+result.data.data.gdRecid);
                    } else if (result.data.status === "1001") {
                        Toast(result.data.msg);
                    } else if (result.data.status == "4001" || result.data.status == "5005" || result.data.status == "1002") {
                        Toast(result.data.msg);
                    } else if (result.data.status === "5001") {
                        Toast(result.data.msg);
                    }
                }, error => {
                    Toast("网络异常");
                    console.log("getuserinfo request error:" + error);
                });
            },
            // 获取车牌颜色名称
                getCarColorName(code) {
                  var goodsTypes = [
                    {
                      code: "1",
                      name: "蓝色"
                    },
                    {
                      code: "2",
                      name: "黄色"
                    },
                    {
                      code: "3",
                      name: "黑色"
                    },
                    {
                      code: "4",
                      name: "白色"
                    },
                    {
                      code: "5",
                      name: "黄绿"
                    },
                    {
                      code: "6",
                      name: "渐变绿"
                    },
                    {
                      code: "9",
                      name: "其他"
                    }
                  ];
                  var name;
                  goodsTypes.forEach(item => {
                    if (item.code === code) {
                      name = item.name;
                    }
                  });
                  return name;
              },
    getGoodsTypeNmae(code) {// 获取货物类型名称
      var goodsTypes = [
        {
          code: "1",
          name: "煤炭及制品"
        },
        {
          code: "2",
          name: "金属矿石"
        },
        {
          code: "3",
          name: "矿建材料及水泥"
        },
        {
          code: "4",
          name: "机械设备电器"
        },
        {
          code: "5",
          name: "轻工医药产品"
        },
        {
          code: "6",
          name: "鲜活农产品"
        },
        {
          code: "9",
          name: "其他"
        }
      ];
      var name = "";
      goodsTypes.forEach(item => {
        if (item.code === code) {
          name = item.name;
        }
      });
      return name;
    }
  }
};
</script>